package com.atguigu.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.atguigu.base.BaseDao;
import com.atguigu.base.BaseServiceImpl;
import com.atguigu.dao.UserInfoDao;
import com.atguigu.entity.UserInfo;
import com.atguigu.service.UserInfoService;
import com.atguigu.util.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 杨林
 * @create 2022-09-24 10:54 星期六
 * description:
 */
@Transactional
@Service(interfaceClass = UserInfoService.class)
public class UserInfoServiceImpl extends BaseServiceImpl<UserInfo> implements UserInfoService {

    @Autowired
    private UserInfoDao userInfoDao;

    @Override
    protected BaseDao<UserInfo> getEntityDao() {
        return userInfoDao;
    }

    /**
     * 根据手机号获取用户信息
     * @param phone
     * @return
     */
    @Override
    public UserInfo getByPhone(String phone) {

        return userInfoDao.getByPhone(phone);
    }

    @Override
    public int insert(UserInfo userInfo) {

        //对密码进行加密操作
        userInfo.setPassword(MD5.encrypt(userInfo.getPassword()));

        return userInfoDao.insert(userInfo);

    }
}
